home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Frameworks / Extension Shell 1.3 / Sample Extensions / Bell Test ƒ / PlaySound.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-06  |  2.3 KB  |  101 lines  |  [TEXT/R*ch]

  1. /*    NAME:
  2.         PlaySound.c
  3.  
  4.     WRITTEN BY:
  5.         Dair Grant
  6.                 
  7.     DESCRIPTION:
  8.         This file contains a CODE resource to be installed as a code block in
  9.         the System Heap.
  10.  
  11.     NOTES:
  12.         •    We retrieve the handle to sound to play from the address table, and play it.
  13.  
  14.     ___________________________________________________________________________
  15.  
  16.     VERSION HISTORY:
  17.         (Jan 1994, dg)
  18.             •    First publicly distributed version.
  19.  
  20.         (Mar 1994, dg)
  21.             •    Extended address table, uses code block to play sound.
  22.  
  23.  
  24.     ___________________________________________________________________________
  25. */
  26. //=============================================================================
  27. //        Include files                                                                     
  28. //-----------------------------------------------------------------------------
  29. #include <GestaltEqu.h>
  30. #include <Sound.h>
  31. #include "StandaloneCode.h"
  32. #include "BTAddrsTable.h"
  33. #include "ESConstants.h"
  34. #include "CodeConstants.h"
  35.  
  36.  
  37.  
  38.  
  39.  
  40. //=============================================================================
  41. //        Global Variables                                                                 
  42. //-----------------------------------------------------------------------------
  43. Handle        gTheSoundToPlay;
  44. Boolean        gAlreadyRan=false;
  45.  
  46.  
  47.  
  48.  
  49.  
  50. //=============================================================================
  51. //        Private function prototypes                             
  52. //-----------------------------------------------------------------------------
  53. pascal    void main(void);
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. //=============================================================================
  65. //        main : Entry point to our code resource.                                                                 
  66. //-----------------------------------------------------------------------------
  67. //        Note :    We get hold of the handle to the sound from our address table,
  68. //                and play it.
  69. //-----------------------------------------------------------------------------
  70. pascal void main(void)
  71. {    BTAddressTable    *theAddressTable;
  72.     OSErr            theErr;
  73.  
  74.  
  75.  
  76.  
  77.     // Get access to our globals, and save off A4
  78.     PatchGetGlobals();
  79.  
  80.     
  81.     
  82.     // If we've not already been called, call the Gestalt selector to get
  83.     // the handle to the sound to play.
  84.     if (!gAlreadyRan)
  85.         {
  86.         Gestalt(kBellTestAddressTable, &theAddressTable);        
  87.         gTheSoundToPlay    = theAddressTable->theSound;
  88.         gAlreadyRan        = true;
  89.         }
  90.     
  91.  
  92.     
  93.     // Play the sound
  94.     theErr = SndPlay(nil, gTheSoundToPlay, true);
  95.  
  96.  
  97.  
  98.     // Restore A4 for our caller
  99.     PatchUngetGlobals();
  100. }
  101.